import Book.Book;
import Book.Bookshelf;
import People.Administrator;
import People.Person;
import People.User;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Bookshelf bookshelf = new Bookshelf();

        //体现了面向对象的思想
        Person user = readyText();
        while (true) {
            int index = user.menu();
            user.iOperations[index].working(bookshelf);
        }


    }

    public static Person readyText(){
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入您的姓名：");
        String name = scanner.nextLine();
        System.out.print("请输入您的身份： 1.管理员  2.普通用户：");
        int identityNumber = scanner.nextInt();
        while (true) {
            if(identityNumber == 1){
                return new Administrator(name);
            }else if (identityNumber == 2){
                return new User(name);
            }else {
                System.out.println("您输入的数字有误！！！");
            }
        }

    }
}
